package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServicePackagessupplies;
import com.ruoyi.service.service.IServicePackagessuppliesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 耗材包与耗材对照Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/packagessupplies")
public class ServicePackagessuppliesController extends BaseController
{
    @Autowired
    private IServicePackagessuppliesService servicePackagessuppliesService;

    /**
     * 查询耗材包与耗材对照列表
     */
    @PreAuthorize("@ss.hasPermi('service:packagessupplies:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServicePackagessupplies servicePackagessupplies)
    {
        startPage();
        List<ServicePackagessupplies> list = servicePackagessuppliesService.selectServicePackagessuppliesList(servicePackagessupplies);
        return getDataTable(list);
    }

    /**
     * 导出耗材包与耗材对照列表
     */
    @PreAuthorize("@ss.hasPermi('service:packagessupplies:export')")
    @Log(title = "耗材包与耗材对照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServicePackagessupplies servicePackagessupplies)
    {
        List<ServicePackagessupplies> list = servicePackagessuppliesService.selectServicePackagessuppliesList(servicePackagessupplies);
        ExcelUtil<ServicePackagessupplies> util = new ExcelUtil<ServicePackagessupplies>(ServicePackagessupplies.class);
        util.exportExcel(response, list, "耗材包与耗材对照数据");
    }

    /**
     * 获取耗材包与耗材对照详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:packagessupplies:query')")
    @GetMapping(value = "/{packagessuppliesId}")
    public AjaxResult getInfo(@PathVariable("packagessuppliesId") Long packagessuppliesId)
    {
        return success(servicePackagessuppliesService.selectServicePackagessuppliesByPackagessuppliesId(packagessuppliesId));
    }

    /**
     * 新增耗材包与耗材对照
     */
    @PreAuthorize("@ss.hasPermi('service:packagessupplies:add')")
    @Log(title = "耗材包与耗材对照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServicePackagessupplies servicePackagessupplies)
    {
        return toAjax(servicePackagessuppliesService.insertServicePackagessupplies(servicePackagessupplies));
    }

    /**
     * 修改耗材包与耗材对照
     */
    @PreAuthorize("@ss.hasPermi('service:packagessupplies:edit')")
    @Log(title = "耗材包与耗材对照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServicePackagessupplies servicePackagessupplies)
    {
        return toAjax(servicePackagessuppliesService.updateServicePackagessupplies(servicePackagessupplies));
    }

    /**
     * 删除耗材包与耗材对照
     */
    @PreAuthorize("@ss.hasPermi('service:packagessupplies:remove')")
    @Log(title = "耗材包与耗材对照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packagessuppliesIds}")
    public AjaxResult remove(@PathVariable Long[] packagessuppliesIds)
    {
        return toAjax(servicePackagessuppliesService.deleteServicePackagessuppliesByPackagessuppliesIds(packagessuppliesIds));
    }
}
